# -*- coding: utf-8 -*-
import configparser
import os


class Config:
    """读取config.ini"""

    def __init__(self, selection):
        # 获取绝对路径
        path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
        print(path)
        # 实例化
        config = configparser.ConfigParser()
        config.read(path + '/config.ini')
        self.config = config
        if selection:
            self.selection = selection

    def get(self, obj, selection=''):
        value = selection
        if self.selection:
            value = self.selection
        return self.config.get(value, obj)
